# Copyright (C) 2007 "dbsolution sas" 
#
# This file is part of Weebotee.
#
# Weebotee is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Weebotee is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Weebotee.  If not, see <http://www.gnu.org/licenses/>.

from django.conf.urls.defaults import *

###
# REDIRECTION WORKAROUND...TO BE CHANGED!!!
###
urlpatterns = patterns('django.views.generic.simple',
    ('^$', 'redirect_to', {'url': '/admin/contents/'}),
)

urlpatterns += patterns('apps.core.backend.views',
   (r'admin/$', 'admin.admin'),

   #utenti
   #(r'users/registration/', 'users.registerUser'),
   (r'users/registration/$', 'users.registerUserProxy'),
   (r'users/add/$', 'users.addUser'), 
   (r'users/(?P<name>[a-zA-Z0-9-_.]+)/delete/$', 'users.deleteUser'), 
   (r'users/(?P<name>[a-zA-Z0-9-_.]+)(/|\b)$', 'users.editUser'),
   (r'users/(?P<name>[a-zA-Z0-9-_.]+)(/|\b)/view/$', 'users.profileDetails'),
   (r'users/(?P<name>[a-z0-9-_.]+)/paymethod/$','paymethod.list'),
   (r'users/(?P<name>[a-z0-9-_.]+)/paymethod/add/$','paymethod.update'),
   (r'users/(?P<name>[a-z0-9-_.]+)/paymethod/(?P<billing_id>\d+)/view/$','paymethod.viewDetails'),
   (r'users/(?P<name>[a-z0-9-_.]+)/paymethod/(?P<billing_id>\d+)/$','paymethod.update'),   
   (r'users/(?P<name>[a-z0-9-_.]+)/paymethod/(?P<billing_id>\d+)/delete/$','paymethod.delete'),
   (r'users/$', 'users.users'),

   #gruppi
   (r'groups/$', 'groups.GroupList'),
   (r'groups/add/$','groups.GroupAdd'),
   (r'groups/(?P<name>[a-z0-9-_.]+)/$', 'groups.GroupMod'),
   #albero contenuti
   (r'contents/$', 'sections.read'),
   
   # Element
   (r'contents/(?P<section_id>\d+)/add/$','elements.generic_add'),
   (r'contents/(?P<section_id>\d+)/(?P<element_type>\S+)/add/$', 'elements.add'),
   
   (r'(?P<element_type>[a-z0-9-]+)/(?P<element_id>\d+)/delete/$', 'elements.delete'),
   (r'(?P<element_type>[a-z0-9-]+)/add/$', 'elements.add'),
   (r'(?P<element_type>\S+)/(?P<element_id>\d+)/$', 'elements.update'),
   # Ordinamento
   (r'(?P<element_type>[a-z0-9-]+)/(?P<element_id>\d+)/move/(?P<direction>(up|down))/$', 'elements.move'),
)
